/**
 * 功能:TK_SURPLUS_ORDER Dao类
 * 开发人员:chengd
 * 创建时间:2012/10/15 22:29:30
 */
package com.towker.frame.dao.basicData;

import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.springframework.stereotype.Repository;
import com.towker.core.db.BaseDao;
import com.towker.frame.model.basicData.SurplusOrder;

@Repository
@SuppressWarnings("unchecked")
public class SurplusOrderDao extends BaseDao<SurplusOrder, Long>
{
	@Override
	public Class getEntityClass()
	{
		return SurplusOrder.class;
	}
	
	public SurplusOrder getByDepotAndGoods(Integer depotId, Integer goodsId, String coCode) {
		String statementName = getIbatisMapperNamespace() + ".getByDepotAndGoods";
		Map params = new TreeMap<String, Object>();
		params.put("depot_id", depotId);
		params.put("goods_id", goodsId);
		params.put("co_code", coCode);
		List<SurplusOrder> surplusOrders = getSqlSessionTemplate().selectList(statementName, params);
		if (surplusOrders.size() > 0) {
			return surplusOrders.get(0);
		}
		return null;
	}

	public SurplusOrder getByDepotCodeAndGoodsId(String depotCode, int goodsId) {
		String statementName = getIbatisMapperNamespace() + ".getByDepotCodeAndGoodsId";
		Map params = new TreeMap<String, Object>();
		params.put("depot_code", depotCode);
		params.put("goods_id", goodsId);
		List<SurplusOrder> surplusOrders = getSqlSessionTemplate().selectList(statementName, params);
		if (surplusOrders.size() > 0) {
			return surplusOrders.get(0);
		}
		return null;
	}
}